//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Common
//  File name:	SqlQueryBuilderContainsItem.cs
//  Developer:	Solomatov Igor
//  Created:	15.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System.ComponentModel;

namespace Smart.Common.Entities
{
	[Localizable(false)]
	public class SqlQueryBuilderContainsItem<TExecutorType> : SqlQueryBuilderConditionItem<TExecutorType>
		where TExecutorType : class
	{
		public SqlQueryBuilderContainsItem(string field, string valueType, string value)
			: base(field, "CONTAINS", null)
		{
			Value = value;
		}

		/// <summary>
		/// Format QueryBuilder statement
		/// </summary>
		public override string FormatQuery()
		{
			var fieldName = (Query == null ? Field : Query.Meta.FieldName(Field));

			return
				string.Format("{1}({0},{2})", fieldName, Op, Value.IncapsulateSql());
		}
	}
}